<?php
Yii::import('application.modules.users.models.User');
Yii::import('application.widgets.DAOTable');
$tbl_name = User::model()->tableName();

$r = '<h1>Stats</h1><h2>Users by status</h2>';
$command = Yii::app()->rdb->createCommand('SELECT status, COUNT(*) AS count FROM '.$tbl_name.' GROUP BY status');
$tbl = new DAOTable($command);
$tbl->setWrap('status',function($name,$value) {return CHtml::link($value,array('/admin/users/showstatus','st' => $value));});
$event->data = $r . $tbl;

$r = '<h1>Operations</h1>';
$r .= CHtml::link('(re)create db structure',array('/admin/users/createdb')) . '<br />';
$r .= CHtml::link('(re)install RBAC support',array('/admin/users/reinstallrbac')) . '<br />';
$r .= CHtml::link('Create User',array('/admin/users/create')) . '<br />';
$r .= CHtml::link('Manage RBAC',array('/admin/users/managerbac'));
$event->data .= $r;
